package db;
import java.util.*;
import entities.*;
public class Tests {


	public static void getItem() {
		DBBookManager.lookupCopy(24);
	}
	public static void addRelnshipTest() {
		Integer[] ints = new Integer[1];
		ints[0] = new Integer(21);
		Integer[] i = new Integer[1];
		i[0] = 18;
		DbRequestManager.addRequest(ints, 24, i);
	}
	
	public static void findOwnerItemsTest() {
		DBBookManager.findOwnerItems(18);
	}
	
	public static void searchBooksTest() {
		ArrayList<Item> it2 = DBBookManager.searchResults("new book", "book", 2);
		System.out.println(it2.size());
	}
	
	public static void searchUsersTest() {
		List<User> users = DBUserManager.searchUser("Vilas", "Roy", 18);
	}
	
	public static void searchResultsTest() {
		DBBookManager.searchResults("harry potter", "book");
	}
	
	public static void addUserTest(){
		
			
		HashMap<String,String> data=new HashMap<String,String>();
		User user=new User();
		user.setUserName("maryam@gmail.com");
		user.setUserType("user");
	    user.setFirstName("maryam");
	    user.setLastName("quadir");
	    user.setPassword("helloworld");
	    user.setPhoneNumber("123COOL");
	   
		int id=DBUserManager.addNewUser(user);
		System.out.println("Id returned of newly added user " + id);
		
	}
	
	public static void isfriendtest() {
		System.out.println(DbRelationshipManager.friend(19, 22));
		System.out.println(DbRelationshipManager.friend(17,16));
	}
	
	public static void isantifriendtest() {
		System.out.println(DbRelationshipManager.antifriend(19, 22));
		System.out.println(DbRelationshipManager.antifriend(18,16));
		System.out.println(DbRelationshipManager.antifriend(16,18));
		System.out.println(DbRelationshipManager.antifriend(18,26));	
	}

	public static void getFriendTest() {
		DbRelationshipManager.getFriends(18);
		DbRelationshipManager.getFriends(19);
		DbRelationshipManager.getFriends(22);
		
	}

	public static void getAntifriendTest() {
		DbRelationshipManager.getAntifriends(18);
		DbRelationshipManager.getAntifriends(22);
		DbRelationshipManager.getAntifriends(26);
		
	}

	public static void delFriendTest() {
		DbRelationshipManager.deleteFriend(19, 22);
		DbRelationshipManager.deleteFriend(16, 17);		
	}
	
	public static void addFriendTest() {
		// Legitimate input
		DbRelationshipManager.makeFriend(19, 18);
		
		// Friends
		DbRelationshipManager.makeFriend(18, 26);
		DbRelationshipManager.makeFriend(26, 18);
		
		// Anti friends
		DbRelationshipManager.makeFriend(19, 22);
		DbRelationshipManager.makeFriend(22, 19);
		
	}
	
	public static void addAntifriendTest() {
		DbRelationshipManager.makeAntifriend(19,22);
		DbRelationshipManager.makeAntifriend(19,18);
		DbRelationshipManager.makeAntifriend(16,26);
		DbRelationshipManager.makeAntifriend(18,26);
		DbRelationshipManager.makeAntifriend(26,18);
	}
	
	public static void updateTest(){
		User u=DBUserManager.lookupUser("maryamisgreat6","blah");
		u.setFirstName("MaryamAwesome");
		System.out.println("DB update successful: " + DBUserManager.updateUser(u));
	}
	
	public static void lookupUserTest(){
		User u=DBUserManager.lookupUser("maryamisgreat6","blah");
		System.out.println(u.getUserId());
	}
	
	public static void updateCopy() {
		Item item = new Item();
		item.setCopyId(26);
		item.setCopyStatus(Item.inLib);
		item.setVisible("public");
		DBBookManager.updateCopy(item);
	}
	
	public static void deleteRequest() {
		System.out.println(DbRequestManager.deleteCopyRequest(6));
	}

	public static void main(String arg[]){
		deleteRequest();
	}
}
